package com.lonely.fx.spinner;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Spinner;
import javafx.scene.control.SpinnerValueFactory;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

/**
 * @date: 2022-07-19 21:16
 * @author: ztkj-hzb
 * @description: 文本框(类似h5的数字框效果) --  基于double数据类型
 **/
public class SpinnerWithDoubleSettingMain extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    /**
     *
     */
    @Override
    public void start(Stage primaryStage) throws Exception {

        HBox hBox = new HBox();

        //创建spinner
        Spinner<Double> doubleSpinner = new Spinner<>(0.0, 100.0, 20.5, 5.5);

        doubleSpinner.getStyleClass().add(Spinner.STYLE_CLASS_ARROWS_ON_RIGHT_HORIZONTAL);

        //设置value工厂
        doubleSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(30,70.0,50,10));

        hBox.getChildren().addAll(doubleSpinner);
        primaryStage.setScene(new Scene(hBox));
        primaryStage.setWidth(600);
        primaryStage.setHeight(500);
        primaryStage.show();
    }
}
